Skip to main content

Create Contact

Description

Create a new contact.

Authentication

  • Required: Yes
  • Roles: Any authenticated user

Request

Headers

POST /v1/customer/contact
Authorization: Bearer <token>
Content-Type: application/json

Request Body

{
"name": "John Doe",
"phone": "0123456789",
"email": "john@example.com",
"age": 30,
"address": "123 Main St",
"assigned": 1,
"type": "contact",
"status": "pending"
}

Field Descriptions

name:

  • Type: string
  • Required: Yes
  • Description: Contact's full name

phone:

  • Type: string
  • Required: Yes
  • Description: Contact's phone number (minimum 5 characters)

email:

  • Type: string
  • Required: No
  • Description: Contact's email address

age:

  • Type: number
  • Required: No
  • Description: Contact's age (positive integer)

address:

  • Type: string
  • Required: No
  • Description: Contact's address

assigned:

  • Type: number
  • Required: No
  • Description: ID of assigned user (nullable)

type:

  • Type: string
  • Required: Yes
  • Description: Contact type (contact, lead, archive)

status:

  • Type: string
  • Required: Yes
  • Description: Contact status (pending, inprocess, conversion, failure)

Response

Success Response (201)

{
"data": {
"id": 1,
"name": "John Doe",
"phone": "0123456789",
"email": "john@example.com",
"age": 30,
"address": "123 Main St",
"assigned": 1,
"type": "contact",
"status": "pending",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}

Error Responses

Error Codes

  • E001_BAD_MISSING_DATA: Missing required fields
  • E006_BAD_DUPLICATE_PHONE: Phone number already exists
  • E007_BAD_DUPLICATE_EMAIL: Email address already exists

Example Usage

curl -X POST https://api.stepx.io.vn/v1/customer/contact \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"phone": "0123456789",
"email": "john@example.com",
"type": "contact",
"status": "pending"
}'
const response = await fetch('https://api.stepx.io.vn/v1/customer/contact', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'John Doe',
phone: '0123456789',
email: 'john@example.com',
type: 'contact',
status: 'pending'
})
});

const data = await response.json();